package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.ImportLogBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.ImportLogMapper;
import cn.uexpo.lhz.domain.ImportLog;
import cn.uexpo.lhz.domain.ImportLogExample;

@Transactional
@Service
public class ImportLogBizImpl implements ImportLogBiz {

	@Autowired
	private ImportLogMapper importLogMapper;
	@Override
	public int insert(ImportLog record) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.insert(record);
	}

	@Override
	public int insertSelective(ImportLog record) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(ImportLog record) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		for (Integer id : ids) {
			importLogMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<ImportLog> records) throws BOException {
		// TODO Auto-generated method stub
		for (ImportLog record : records) {
			importLogMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(ImportLogExample example) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(ImportLog record) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(ImportLog record) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(ImportLog record, ImportLogExample example) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(ImportLog record, ImportLogExample example) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.updateByExample(record,example);
	}

	@Override
	public ImportLog selectByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.selectByPrimaryKey(id);
	}

	@Override
	public ImportLog selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		ImportLog item=null;
		ImportLogExample example=new ImportLogExample();
		ImportLogExample.Criteria citeria=example.createCriteria();
		 citeria.andExtstr3EqualTo(uniqueCode);
		 List<ImportLog> items=importLogMapper.selectByExample(example);
		 if (items!=null&&items.size()>0) {
			 item=items.get(0);
		}
		return item;
	}

	@Override
	public List<ImportLog> selectByExample(ImportLogExample example) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.selectByExample(example);
	}

	@Override
	public long countByExample(ImportLogExample example) throws BOException {
		// TODO Auto-generated method stub
		return importLogMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, ImportLogExample example) throws BOException {
		int pageNum = pageRequest.getPage();
	    int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<ImportLog> records = (List<ImportLog>) importLogMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<ImportLog>(records));
	}

	@Override
	public List<String> selectDistinctProTypes() throws BOException {
		return importLogMapper.selectDistinctProTypes();
	}
	@Override
	public List<String> selectDistinctFileNames() throws BOException {
		return importLogMapper.selectDistinctFileNames();
	}
	@Override
	public List<String> selectDistinctCodes() throws BOException {
		return importLogMapper.selectDistinctCodes();
	}


}
